home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / cli / master60.zoo / master / tools / readhist / csystem.s next >
Encoding:
Text File  |  1990-10-18  |  1.4 KB  |  81 lines

  1.         include    "toseq.inc"
  2.  
  3.         import    system
  4.         export    csystem
  5.  
  6. *
  7. * csystem(str)
  8. *
  9. csystem:    move.l    A0,ToPutIs        ; str
  10.  
  11.         ; install new handler
  12.         pea    NewTrap
  13.         move.w    #trap1>>2,-(a7)
  14.         move.w    #Setexc,-(a7)
  15.         trap    #BIOS
  16.         addq.l    #8,a7
  17.         move.l    d0,OldTrap
  18.  
  19.         ; call interactive system
  20.         lea    empty,a0
  21.         bra    system
  22.         
  23. OldSp:        dc.l    0
  24. StatusReg:    dc.w    0
  25.         dc.l    "XBRA"
  26.         dc.l    "CSYS"
  27. OldTrap:    dc.l    0
  28. NewTrap:
  29.         move.w    sr,StatusReg
  30.         ori.w    #0x700,sr        ; lock interrupts
  31.         move.l    a7,OldSp
  32.         btst    #13,(a7)        ; call from user mode ?
  33.         bne    handler            ;  no -> a7 ok
  34.         move.l    usp,a0            ; put parameter on user stack
  35.         move.l    2(a7),-(a0)        ; pc
  36.         move.w    (a7),-(a0)        ; sr
  37.         move.l    a0,a7
  38.  
  39. handler:    move.w    StatusReg,sr
  40.         move.w    6(a7),d0        ; functioncode
  41.         
  42.         ; check for valid function
  43.         cmp.w    #Cconis,d0
  44.         beq    NewCconis
  45.         cmp.w    #Crawcin,d0
  46.         beq    NewCrawcin
  47.  
  48. OldFunction:    move.l    OldSp,a0
  49.         move.w    (a7),(a0)        ; sr
  50.         move.l    2(a7),2(a0)        ; pc
  51.         move.l    a0,a7
  52.  
  53.         move.l    OldTrap,a0
  54.         jmp    (a0)
  55.  
  56. NewCconis:
  57.         move.l    ToPutIs,a0
  58.         tst.b    (a0)
  59.         beq    ThereWasNo
  60.         move.b    #1,d0
  61.         bra    TrapExit
  62.         
  63. NewCrawcin:
  64.         move.l    ToPutIs,a0
  65.         move.b    (a0)+,d0
  66.         bne    ThereWasOne
  67. ThereWasNo:
  68.         move.l    OldTrap,trap1
  69.         bra    OldFunction
  70. ThereWasOne:
  71.         move.l    a0,ToPutIs
  72.  
  73. TrapExit:    move.l    OldSp,a0
  74.         move.w    (a7),(a0)        ; sr
  75.         move.l    2(a7),2(a0)        ; pc
  76.         move.l    a0,a7
  77.         rte
  78.  
  79. ToPutIs:    dc.l    0
  80. empty:        dc.b    0
  81.